#include "stdafx.h"
#include "SecondTimer.h"
#include <time.h>

void CTimer::Subscribe( CTimerSubscriber * pSubscriber )
{
    m_Subscribers.insert(pSubscriber);
}

void CTimer::UnSubscribe( CTimerSubscriber * pSubscriber )
{
    m_Subscribers.erase(pSubscriber);
}

void CTimer::NotifyAll()
{
    time_t tNow = time(NULL);
    TSubscribers::iterator i = m_Subscribers.begin();
    while(i != m_Subscribers.end())
    {
        TSubscribers::iterator j = i++;
        (*j)->OnTrigger(tNow);
    }
}
